Robotics 1.0 Lesson Plan
Lesson 7 - Clap It On

Purpose: Use the CPX's sound sensor to detect sound and trigger a light.

No. of Classes

1 class (Duration: 1 hour 30 minutes; maximum 4 students per group).

Materials Required
  • Software
  • Laptop or desktop with Mu Editor installed.

    CircuitPython installed on the CPX board.

  • Hardware
  • Circuit Playground Express (CPX) board with USB cable.

    Relay.

    External battery.

    Bulb.

    Jumper wires.

Prior Knowledge

Understanding of sensors.

Basic Python syntax (loops, if-else, functions).

Exercises

Exercise 1



Defining a function in Python

  • Here is the instruction file.
  • Exercise 2



    Reading sound sensor values from the CPX.

  • Here is the instruction file.
  • Exercise 3



    Connect an externally powered light to the CPX and control ON/OFF by detecting a clap sound.

    1. Connection part for relay and light with CPX (Recap: Lesson Plan 5).

  • Click here.

  • 2. Here is a document showing code hints (pseudocode):

  • Click here.
  • Teacher’s Instructions
    1. Go around and check if students are facing any issues, and help them troubleshoot.
    2. Ask students whether this task can be done using external sensors instead of the built-in CPX sensors.
    3. Emphasize safety when using external batteries.
    4. Discuss with students why we need functions.
    5. Discuss how this can be used in real life (automatic lamps, alarms, etc.).
    6. When a function is called again and again, does it remember the old values inside it, or does it start fresh? Why?